;layui.define(function(e) {
    layui.use(['table','layer','form','laydate'], function(){
        var $ = layui.$
            ,layer = layui.layer
            ,form = layui.form
            ,table = layui.table
            ,laydate = layui.laydate;

        // 意向单表格数据start
       var purchasingTable1=layui.table;
        purchasingTable1.render({
            elem: '#idTest1'
            ,cols: [[ //标题栏
                {field: 'orderNub', title: '订单号', fixed:'left'}
                ,{field: 'id', title: 'ID'}
                ,{field: 'dealer', title: '经销商'}
                ,{field: 'shipAddress', title: '发货地址'}
                ,{field: 'orderOnTime', title: '下订时间'}
                ,{field: 'orderOnNub', title: '下订数量'}
                ,{field: 'payment', title: '支付方式'}
                ,{field: 'name', title: '接车人姓名'}
                ,{field: 'telephone', title: '接车人电话'}
                ,{field: 'type', title: '配送方式'}
                ,{field: 'status', title: '订单状态'}
                ,{field: 'tool',title: '操作',fixed: 'right', align:'center', toolbar: '#barDemo1'}
            ]]
            ,cellMinWidth: 120
            ,data: [{
                "orderNub": "123456789"
                ,"id": "10001"
                ,"dealer": "杜甫"
                ,"shipAddress": "xianxin@layui.com"
                ,"orderOnTime": "男"
                ,"orderOnNub": "浙江杭州"
                ,"payment": "人生恰似一场修行"
                ,"name": "116"
                ,"telephone": "116"
                ,"type": "116"
                ,"status": "116"
                ,"tool": "2016-10-14"
            }]
            ,page: true //是否显示分页
        });
        //监听意向单工具条
        purchasingTable1.on('tool(listTable1)', function(obj){
            var data = obj.data;
            if(obj.event === 'enter'){
                var index = layer.open({
                    type: 2
                    ,id: (new Date()).valueOf()
                    ,title: '待平台确认'
                    ,content: 'step1.html'
                    ,area: ['500px', '500px']
                    ,maxmin: true
                    ,success: function(layero, index){
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    }
                });
                layer.full(index);
            }
        });
        // 意向单表格数据end

        // 意向单表格数据start
        var purchasingTable2=layui.table;
        purchasingTable2.render({
            elem: '#idTest2'
            ,cols: [[ //标题栏
                {field: 'orderNub', title: '订单号', fixed:'left'}
                ,{field: 'id', title: 'ID'}
                ,{field: 'dealer', title: '经销商'}
                ,{field: 'shipAddress', title: '发货地址'}
                ,{field: 'orderOnTime', title: '下订时间'}
                ,{field: 'orderOnNub', title: '下订数量'}
                ,{field: 'payment', title: '支付方式'}
                ,{field: 'name', title: '接车人姓名'}
                ,{field: 'telephone', title: '接车人电话'}
                ,{field: 'type', title: '配送方式'}
                ,{field: 'status', title: '订单状态'}
                ,{field: 'tool',title: '操作',fixed: 'right', align:'center', toolbar: '#barDemo2'}
            ]]
            ,cellMinWidth: 120
            ,data: [{
                "orderNub": "123456789"
                ,"id": "10002"
                ,"dealer": "杜甫"
                ,"shipAddress": "xianxin@layui.com"
                ,"orderOnTime": "男"
                ,"orderOnNub": "浙江杭州"
                ,"payment": "人生恰似一场修行"
                ,"name": "116"
                ,"telephone": "116"
                ,"type": "116"
                ,"status": "116"
                ,"tool": "2016-10-14"
            }]
            ,page: true //是否显示分页
        });
        //监听意向单工具条
        purchasingTable2.on('tool(listTable2)', function(obj){
            var data = obj.data;
            if(obj.event === 'enter'){
                var index = layer.open({
                    type: 2
                    ,id: (new Date()).valueOf()
                    ,title: '进入'
                    ,content: 'step2.html'
                    ,area: ['500px', '500px']
                    ,maxmin: true
                    ,success: function(layero, index){
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    }
                });
                layer.full(index);
            }
        });
        // 意向单表格数据end

        // 意向单表格数据start
        var purchasingTable3=layui.table;
        purchasingTable3.render({
            elem: '#idTest3'
            ,cols: [[ //标题栏
                {field: 'orderNub', title: '订单号',fixed:'left'}
                ,{field: 'id', title: 'ID'}
                ,{field: 'dealer', title: '经销商'}
                ,{field: 'shipAddress', title: '发货地址'}
                ,{field: 'orderOnTime', title: '下订时间'}
                ,{field: 'orderOnNub', title: '下订数量'}
                ,{field: 'payment', title: '支付方式'}
                ,{field: 'name', title: '接车人姓名'}
                ,{field: 'telephone', title: '接车人电话'}
                ,{field: 'type', title: '配送方式'}
                ,{field: 'status', title: '订单状态'}
                ,{field: 'tool',title: '操作',fixed: 'right', align:'center', toolbar: '#barDemo3'}
            ]]
            ,cellMinWidth: 120
            ,data: [{
                "orderNub": "123456789"
                ,"id": "10003"
                ,"dealer": "杜甫"
                ,"shipAddress": "xianxin@layui.com"
                ,"orderOnTime": "男"
                ,"orderOnNub": "浙江杭州"
                ,"payment": "人生恰似一场修行"
                ,"name": "116"
                ,"telephone": "116"
                ,"type": "116"
                ,"status": "116"
                ,"tool": "2016-10-14"
            }]
            ,page: true //是否显示分页
        });
        //监听意向单工具条
        purchasingTable3.on('tool(listTable3)', function(obj){
            var data = obj.data;
            if(obj.event === 'enter'){
                var index = layer.open({
                    type: 2
                    ,id: (new Date()).valueOf()
                    ,title: '进入'
                    ,content: 'step3.html'
                    ,area: ['500px', '500px']
                    ,maxmin: true
                    ,success: function(layero, index){
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    }
                });
                layer.full(index);
            }
        });
        // 意向单表格数据end

        // 意向单表格数据start
        var purchasingTable4=layui.table;
        purchasingTable4.render({
            elem: '#idTest4'
            ,cols: [[ //标题栏
                {field: 'orderNub', title: '订单号', fixed:'left'}
                ,{field: 'id', title: 'ID'}
                ,{field: 'dealer', title: '经销商'}
                ,{field: 'shipAddress', title: '发货地址'}
                ,{field: 'orderOnTime', title: '下订时间'}
                ,{field: 'orderOnNub', title: '下订数量'}
                ,{field: 'payment', title: '支付方式'}
                ,{field: 'name', title: '接车人姓名'}
                ,{field: 'telephone', title: '接车人电话'}
                ,{field: 'type', title: '配送方式'}
                ,{field: 'status', title: '订单状态'}
                ,{field: 'tool',title: '操作',fixed: 'right', align:'center', toolbar: '#barDemo4'}
            ]]
            ,cellMinWidth: 120
            ,data: [{
                "orderNub": "123456789"
                ,"id": "10004"
                ,"dealer": "杜甫"
                ,"shipAddress": "xianxin@layui.com"
                ,"orderOnTime": "男"
                ,"orderOnNub": "浙江杭州"
                ,"payment": "人生恰似一场修行"
                ,"name": "116"
                ,"telephone": "116"
                ,"type": "116"
                ,"status": "116"
                ,"tool": "2016-10-14"
            }]
            ,page: true //是否显示分页
        });
        //监听意向单工具条
        purchasingTable4.on('tool(listTable4)', function(obj){
            var data = obj.data;
            if(obj.event === 'enter'){
                var index = layer.open({
                    type: 2
                    ,id: (new Date()).valueOf()
                    ,title: '进入'
                    ,content: 'step4.html'
                    ,area: ['500px', '500px']
                    ,maxmin: true
                    ,success: function(layero, index){
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    }
                });
                layer.full(index);
            }
        });
        // 意向单表格数据end

        // 意向单表格数据start
        var purchasingTable5=layui.table;
        purchasingTable5.render({
            elem: '#idTest5'
            ,cols: [[ //标题栏
                {field: 'orderNub', title: '订单号', fixed:'left'}
                ,{field: 'id', title: 'ID'}
                ,{field: 'dealer', title: '经销商'}
                ,{field: 'shipAddress', title: '发货地址'}
                ,{field: 'orderOnTime', title: '下订时间'}
                ,{field: 'orderOnNub', title: '下订数量'}
                ,{field: 'payment', title: '支付方式'}
                ,{field: 'name', title: '接车人姓名'}
                ,{field: 'telephone', title: '接车人电话'}
                ,{field: 'type', title: '配送方式'}
                ,{field: 'status', title: '订单状态'}
                ,{field: 'tool',title: '操作',fixed: 'right', align:'center', toolbar: '#barDemo5'}
            ]]
            ,cellMinWidth: 120
            ,data: [{
                "orderNub": "123456789"
                ,"id": "10005"
                ,"dealer": "杜甫"
                ,"shipAddress": "xianxin@layui.com"
                ,"orderOnTime": "男"
                ,"orderOnNub": "浙江杭州"
                ,"payment": "人生恰似一场修行"
                ,"name": "116"
                ,"telephone": "116"
                ,"type": "116"
                ,"status": "116"
                ,"tool": "2016-10-14"
            }]
            ,page: true //是否显示分页
        });
        //监听意向单工具条
        purchasingTable5.on('tool(listTable5)', function(obj){
            var data = obj.data;
            if(obj.event === 'enter'){
                var index = layer.open({
                    type: 2
                    ,id: (new Date()).valueOf()
                    ,title: '进入'
                    ,content: 'step5.html'
                    ,area: ['500px', '500px']
                    ,maxmin: true
                    ,success: function(layero, index){
                        var body = layer.getChildFrame('body', index);
                        var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    }
                });
                layer.full(index);
            }
        });
        // 意向单表格数据end

        //生成采购单
        $("#purchaseOrder").click(function () {
            var index = layer.open({
                type: 2
                ,id: (new Date()).valueOf()
                ,title: '生成采购单'
                ,content: 'purchaseOrder.html'
                ,area: ['500px', '500px']
                ,maxmin: true
                ,success: function(layero, index){
                    var body = layer.getChildFrame('body', index);
                    var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                }
            });
            layer.full(index);
        })
        //生成延期单
        $("#delayOrder").click(function () {
            var index = layer.open({
                type: 2
                ,id: (new Date()).valueOf()
                ,title: '生成延期单'
                ,content: 'delayOrder.html'
                ,area: ['500px', '500px']
                ,maxmin: true
                ,success: function(layero, index){
                    var body = layer.getChildFrame('body', index);
                    var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                }
            });
            layer.full(index);
        })

        //执行一个laydate实例
        laydate.render({
            elem: '#date1'
        });
        laydate.render({
            elem: '#date2'
        });
        laydate.render({
            elem: '#date3'
        });
        laydate.render({
            elem: '#date4'
        });
        laydate.render({
            elem: '#date5'
        });
        form.render();
    });
    //输出模块
    e("purchasing", {})
});